﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using DAL;
namespace PhongMachTu.Report
{
    public partial class frmBCDoanhThuTheoNgay : Form
    {
        public frmBCDoanhThuTheoNgay()
        {
            InitializeComponent();
            for (int i = 1; i <= 12; i++)
            {
                comboBox1.Items.Add(i);
            }
            comboBox1.Text = DateTime.Now.Month.ToString();
        }
        int Month = DateTime.Now.Month;
        int Year = DateTime.Now.Year;
        private void frmBCDoanhThuTheoNgay_Load(object sender, EventArgs e)
        {

            HoaDonBindingSource.DataSource = GetTable();
            this.reportViewer1.RefreshReport();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Month = int.Parse(comboBox1.Text);
        }
        KhambenhBLL bllKhamBenh = new KhambenhBLL();
        HoaDonBLL bllHoaDon = new HoaDonBLL();

        public DataTable GetTable()
        {
            DataTable table = new DataTable();
            table.Columns.Add("STT", typeof(int));
            table.Columns.Add("Ngày", typeof(int));
            table.Columns.Add("Số Bệnh Nhân", typeof(int));
            table.Columns.Add("Doanh Thu", typeof(int));
            table.Columns.Add("Tỉ Lệ", typeof(int));

            for (int day = 1; day < DateTime.DaysInMonth(Year, Month); day++)
            {
                int stt = 0;
                if (bllKhamBenh.thongKeTheoNgay(day, Month, Year) != 0)
                {
                    table.Rows.Add(stt + 1, day, bllKhamBenh.thongKeTheoNgay(day, Month, Year),
    bllHoaDon.thongKeHoaDonTheoNgay(day, Month, Year), 0);
                }
            }


            return table;
        }
    }
}
